package com.test.web.jdbc.util;

/**
 * com.test.web.jdbc.util
 *
 * @author 白雨浓
 * date: 2018/10/21 12:01
 * content:
 */
public class ColumnUtil {

    public static String camelCaseName(String s) {
        StringBuilder result = new StringBuilder();
        if (s != null && s.length() > 0) {
            boolean flag = false;
            for (int i = 0; i < s.length(); i++) {
                char ch = s.charAt(i);
                if ("_".charAt(0) == ch) {
                    flag = true;
                    continue;
                }

                if (flag) {
                    result.append(Character.toUpperCase(ch));
                    flag = false;
                    continue;
                }

                result.append(ch);
            }
        }
        return result.toString();
    }

    public static String upperCaseFirstOne(String s) {
        if (Character.isUpperCase(s.charAt(0)))
            return s;
        else
            return String.valueOf(Character.toUpperCase(s.charAt(0))) + s.substring(1);
    }
}
